import uuid
import os
def chunk2dbcode(data):
    _data=[]
    ids=[]
    metadatas=[]
    
    for item in data:
        _data.append(item.page_content)
        metadatas.append(item.metadata)
        ids.append(str(uuid.uuid4()))
    return _data,ids,metadatas

def suff(fn):
    suffix = filename.split(".")[-1]
    return suffix

def isDoc(filename):
    suffix = filename.split(".")[-1].lower()

    if suffix == "docx" or suffix == "doc" :
        return True
    return False


def isTxt(filename):
    suffix = filename.split(".")[-1].lower()
    if suffix == "txt":
        return True
    return False

def isPdf(filename):
    suffix = filename.split(".")[-1].lower()
    if suffix == "pdf":
        return True
    return False

import glob 
def pathlist(directory):
    return glob.glob(os.path.join(directory, '*'))
 
import base64
def image_to_base64(image_path):
    with open(image_path, "rb") as image_file:
        encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
    return encoded_string

